package com.jzo2o.foundations.controller;

import com.jzo2o.api.foundations.dto.ServeItemSimpleDTO;
import com.jzo2o.api.foundations.dto.response.ServeTypeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Validated
@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 首页服务查询接口")
public class FirstPageServeController {
    @Resource
    private HomeService homeService;

    @ApiOperation("首页服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass = Long.class)
    })
    @GetMapping("/firstPageServeList")
    public List<ServeCategoryResDTO> firstPageServeList(@RequestParam("regionId") Long regionId) {
        return homeService.firstPageServeList(regionId);
    }
    @GetMapping("/serveTypeList")
    public List<ServeTypeCategoryResDTO> serveTypeList(@RequestParam("regionId") Long regionId) {
        return homeService.serveTypeList(regionId);

    }
    @GetMapping("/hotServeList")
    public List<ServeAggregationSimpleResDTO> hotServeList(@RequestParam("regionId") Long regionId) {
        return homeService.hotServeList(regionId);
    }
    @GetMapping("/{id}")
    public ServeAggregationSimpleResDTO getById(@PathVariable("id") Long id){
        return homeService.getById(id);
    }
    @GetMapping("/search")
    public List<ServeItemSimpleDTO> search(@RequestParam("cityCode") String cityCode, @RequestParam("serveTypeId") Long serveTypeId){
        return homeService.search( cityCode,serveTypeId);
    }
}